package com.bonc.ioc.controller;

import com.bonc.ioc.base.page.PageResult;
import com.bonc.ioc.common.util.AppReply;
import com.bonc.ioc.service.TopicService;
import com.bonc.ioc.vo.TopicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wxf
 * @Title
 * @Package
 * @Description 前台专题
 * @date 2021/4/814:43
 */
@RestController
@RequestMapping("/upTopic")
public class UpTopicController {

    @Autowired
    private TopicService topicService;

    @RequestMapping("/selectByPage")
    public AppReply selectTopicByPage(@RequestParam @NotBlank String pageSize,
                                      @RequestParam @NotBlank String pageNum,
                                      @RequestParam String name,
                                      @RequestParam String timeCount) throws BindException {
        name = name.trim();
        HashMap<String, Object> map = new HashMap<>(16);
        map.put("name",name);
        map.put("timeCount",timeCount);
        PageResult pageResult = topicService.selectTopicByPage(map);
        return AppReply.success(pageResult);
    }

    @RequestMapping("/selectTopicMessageById")
    public AppReply selectTopicMessage(@RequestParam @NotBlank String id) {
        id = id.trim();
        Map<String, Object> message = topicService.selectTopicMessage(id);
        return AppReply.success(message);
    }
}
